package com.tree.common.util;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName com.demo.common.util
 * Description: <类功能描述>. <br>
 * <p>
 * <使用说明>
 * </p>
 * @Author tree
 * @Date 2019-05-25 23:54
 * @Version 1.0
 */
public class Log {
    private String operation;
    private String message;
    private Map<String,Object> kvMap = new HashMap<>();

    public Log(String operation){
        this.operation = operation;
    }

    public static Log op(String operation){
        return new Log(operation);
    }

    public Log msg(String message){
        this.message = message;
        return this;
    }

    public Log kv(String key, Object object){
        this.kvMap.put(key,object);
        return this;
    }
    @Override
    public String toString(){
        return String.format("%s|%s%s",new Object[]{this.operation,this.kvMap.toString(),this.message});
    }

    public static void main(String[] args) {
        System.out.println(Log.op("main").msg("success").kv("name","tree").toString());
    }

}

